<?php //$this->beginContent('application.views.layouts.main'); 
$this->beginContent('/layouts/main');?>

<?php
$model = UserProfiles::model()->findbyPk(Yii::app()->user->id);
?>
<div id="main-content">
    <?php echo $content; ?>
</div>
<div id="sidebar">
    <div class="sidebar-box border-line">
        <div class="sidebar-title">Control Panel</div>
        <div class="sidebar-content">
			<div class="comment-avatar border-shadow"><img src="<?php if($model!=null AND $model->avatar!=null){ ?>  <?php echo Yii::app()->request->baseUrl;?>/data/<?php echo $model->avatar;} else echo Yii::app()->request->baseUrl."/images/noavatar.gif";?>" height="80px" width="80px" /></div>
            <div class="comment-owner"><font color="black" style="font-weight: normal;">Hello </font>
            <?php 
				if($model != null)
					echo CHtml::link(CHtml::encode($model->display_name), array('viewprofiles', 'id'=>Yii::app()->user->id));
				else
					echo CHtml::link(CHtml::encode(Yii::app()->user->name), array('viewprofiles', 'id'=>Yii::app()->user->id));
			?>
            </div>
            <div class="comment-time">
            <?php $this->widget('zii.widgets.CMenu',array(
    			'items'=>array(
    				array('label'=>'Control Panel', 'url'=>array('users/viewprofiles', 'id'=>Yii::app()->user->id), 'visible'=>!Yii::app()->user->isGuest),
                    array('label'=>'(Logout)', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)
    			),
    		)); ?>
            </div>
            <div class="clear"></div>
        </div>
    </div>
	<?php if (!Yii::app()->user->isGuest) {?>
    <div class="sidebar-box border-line">
        <div class="sidebar-title">Thông tin cá nhân</div>
        <div class="sidebar-content">
            <span><?php echo CHtml::link('Profiles', array('users/viewprofiles', 'id'=>Yii::app()->user->id)); ?></span>
            <?php $this->widget('zii.widgets.CMenu',array(
    			'items'=>array(
    				array('label'=>'View Profile', 'url'=>array('users/viewprofiles', 'id'=>Yii::app()->user->id)),
    				array('label'=>'Edit Profile', 'url'=>array('users/editprofiles', 'id'=>Yii::app()->user->id)),
    			),
    		)); ?>
            
            <span><?php echo CHtml::link('Accounts Secury', array('users/view', 'id'=>Yii::app()->user->id)); ?></span>
            <?php $this->widget('zii.widgets.CMenu',array(
    			'items'=>array(
    				array('label'=>'Password', 'url'=>array('users/changepassword', 'id'=>Yii::app()->user->id)),
                    array('label'=>'Email', 'url'=>array('users/changeemail', 'id'=>Yii::app()->user->id)),
    			),
    		)); ?>
            <div class="clear"></div>
        </div>
    </div>
	<?php }?>
</div>
<div class="clear"></div>
<?php $this->endContent(); ?>